$(function () {

    //轮播图
    var count = 0;
    lunbo();
    function yingChan(a) {
        $(".slider>ul>li").eq(a).stop().fadeIn().siblings("li").stop().fadeOut();
        $(".round>ul>li").eq(a).addClass("roundLiHover").siblings("li").removeClass("roundLiHover");
    }
    function lunbo() {
        setInterval(function () {
            count++;
            if (count == $(".slider>ul>li").length) {
                count = 0;
            }
            yingChan(count);
        }, 5000);
    }
    // 下拉菜单
    $('#nav_genduo').on('click', function(){
        $('#nav_dhl').stop().slideToggle();
    })



    //路径导航
    //获取图片路径
    function ljdhSrc(ljdhdz) {
        var ljdh = $(ljdhdz).find('img').attr('src');
        return ljdh;
    }
    var xcpSrc = ljdhSrc("#ljdh_xcp");
    var cpggSrc = ljdhSrc("#ljdh_cpgg");
    var jxdhSrc = ljdhSrc("#ljdh_jxdh");
    var vrarSrc = ljdhSrc("#ljdh_vrar");
    var jhsdmtSrc = ljdhSrc("#ljdh_jhsdmt");
    var szbwgSrc = ljdhSrc("#ljdh_szbwg");
    // 路径导航选择器
    var xcp = $('#ljdh_xcp')
    var cpgg = $('#ljdh_cpgg');
    var jxdh = $('#ljdh_jxdh')
    var vrar = $('#ljdh_vrar');
    var jhsdmt = $('#ljdh_jhsdmt')
    var szbwg = $('#ljdh_szbwg');
    // 路径导航Tab
    function ljdhTab(xcp,cpgg,jxdh,vrar,jhsdmt,szbwg,xcpSrc,cpggSrc,jxdhSrc,vrarSrc,jhsdmtSrc,szbwgSrc) {
        xcp.find('img').attr('src',xcpSrc)
        cpgg.find('img').attr('src',cpggSrc);
        jxdh.find('img').attr('src',jxdhSrc);
        vrar.find('img').attr('src',vrarSrc);
        jhsdmt.find('img').attr('src',jhsdmtSrc);
        szbwg.find('img').attr('src',szbwgSrc);
    }
    $('#ljdh_xcp').on('click', function () {
        scrollTo('#promotional_film', 500);
        ljdhTab(xcp,cpgg,jxdh,vrar,jhsdmt,szbwg,xcpSrc,cpggSrc,jxdhSrc,vrarSrc,jhsdmtSrc,szbwgSrc)
    })
    $('#ljdh_cpgg').on('click', function () {
        scrollTo('#product', 500);
        ljdhTab(xcp,cpgg,jxdh,vrar,jhsdmt,szbwg,'image/ljdh1_1.png','image/ljdh_hov2.png',jxdhSrc,vrarSrc,jhsdmtSrc,szbwgSrc)
    })
    $('#ljdh_jxdh').on('click', function () {
        scrollTo('#Mechanical', 500);

        ljdhTab(xcp,cpgg,jxdh,vrar,jhsdmt,szbwg,'image/ljdh1_1.png',cpggSrc,'image/ljdh_hov3.png',vrarSrc,jhsdmtSrc,szbwgSrc)
    })
    $('#ljdh_vrar').on('click', function () {
        scrollTo('#vr_sz', 500);
        ljdhTab(xcp,cpgg,jxdh,vrar,jhsdmt,szbwg,'image/ljdh1_1.png',cpggSrc,jxdhSrc,'image/ljdh_hov4.png',jhsdmtSrc,szbwgSrc)
    })
    $('#ljdh_jhsdmt').on('click', function () {
        scrollTo('#jhsdmt', 500);
        ljdhTab(xcp,cpgg,jxdh,vrar,jhsdmt,szbwg,'image/ljdh1_1.png',cpggSrc,jxdhSrc,vrarSrc,'image/ljdh_hov5.png',szbwgSrc)
    })
    $('#ljdh_szbwg').on('click', function () {
        scrollTo('#szmtbwg', 500);
        ljdhTab(xcp,cpgg,jxdh,vrar,jhsdmt,szbwg,'image/ljdh1_1.png',cpggSrc,jxdhSrc,vrarSrc,jhsdmtSrc,'image/ljdh_hov6.png')
    })
    $('#phone_footer_top').on('click', function(){
        scrollTo();
    })
    function scrollTo(ele, speed) {
        if (!speed) speed = 500;
        if (!ele) {
            $("html,body").animate({
                scrollTop: 0
            }, speed);
        } else {
            if (ele.length > 0) $("html,body").animate({
                scrollTop: $(ele).offset().top
            }, speed);
        }
        return false;
    }
})